//
//  IconGrid.swift
//  LOTR Converter
//
//  Created by li on 2025/4/3.
//
import SwiftUI

struct IconGrid :View{
    @Binding var currency:Currency
    var body: some View{
        LazyVGrid(columns:[GridItem(),GridItem(),GridItem()] ) {
            ForEach(Currency.allCases){
                currency in
                if currency==self.currency{
                    CurrencyIcon(text:currency.name , icon: currency.image)
                        .shadow(color: .black, radius: 10)
                        .overlay{
                            RoundedRectangle(cornerRadius: 25)
                                .stroke(lineWidth: 3)
                                .opacity(0.5)
                        }
                }else{
                    CurrencyIcon(text:currency.name , icon: currency.image)
                        .onTapGesture {
                            self.currency=currency
                        }
                }
            }
        }
    }
}


#Preview {
    @Previewable @State var currency:Currency = .sliverPenny
    IconGrid(currency: $currency)
}
